﻿@{
    Layout = null;
    ViewBag.Title = "用户注册";
}
<html>
<head>
    <meta charset="UTF-8">
    <title>注册</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
    <meta name="format-detection" content="telphone=no, email=no" />
    <meta name="full-screen" content="yes">
    <meta name="x5-fullscreen" content="true">
    <meta name="msapplication-tap-highlight" content="no">
    <link rel="stylesheet" type="text/css" href="~/Content/css/reset.css" />
    <link rel="stylesheet" type="text/css" href="~/Content/css/swiper.min.css" />
    <link rel="stylesheet" type="text/css" href="~/Content/css/gelunbu.css" />
    <script src="~/Content/js/jquery-3.2.1.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="~/Content/js/layer/1.9.3/layer.js"></script>
    <script src="~/Content/js/web.js"></script>
    <script type="text/javascript">
        function isPoneAvailable(str) {
            var myreg = /^[1][3,4,5,7,8][0-9]{9}$/;
            if (!myreg.test(str)) {
                return false;
            } else {
                return true;
            }
        }
        function region() {
			var $mobile = $("#mobile");
			var $name = $("#name");
			var $code = $("#code");
			var $password = $("#password");
			var $pmobile=$("#p_mobile");
			var error_info="";
			
            if ($mobile.val() == "") {
                error_info="请输入手机号码";
            }
            else if (isPoneAvailable($mobile.val()) == false)
            {
                error_info="请输入正确的手机号码";
            }
            else if ($password.val() == "") {
                error_info="请输入密码!";
            }
			if($pmobile.val() != "" && (isPoneAvailable($pmobile.val()) == false)){
				error_info="请输入正确邀请号码";
			}
			
			if(error_info != ""){
				layer.msg(error_info);
				return;
            }
            ajax({
                url: '/Home/RegisterPost',
                data: { Moblie: $mobile.val(), Password: $password.val(), Name: $name.val(), Code: $code.val(), pMobile: $pmobile.val() },
                actions: 'redirect',
                redirect:'/Home/Index'
            });
        }
      
        var countdown = 60;

        function sendemail() {
			var $mobile = $("#mobile");
            if ($mobile.val() == "") {
                layer.msg("请输入手机号码");
                return;
            }
            ajax({
                url: '/Home/GetCode',
                data: { Mobile: $mobile.val() },
                success_msg: '发送成功',
                fail_msg:'发送失败'
            });
            var obj = $(".get-code");
            settime(obj);
        }
        function settime(obj) { //发送验证码倒计时
            if (countdown == 0) {
                obj.attr('disabled', false);
                //obj.removeattr("disabled");
                obj.val("免费获取验证码");
                countdown = 60;
                return;
            } else {
                obj.attr('disabled', true);
                obj.val("重新发送(" + countdown + ")");
                countdown--;
            }
            setTimeout(function () {
                settime(obj)
            }, 1000)
        }
   
    </script>
</head>
<body>
    <div class="retrieve">
        <section class="group-ipt mt32">
            <input type="text" id="name" class="reset_pwd_ipt" placeholder="请输入昵称" />
        </section>
        <section class="group-ipt">
            <input type="text" id="mobile" class="reset_pwd_ipt"  placeholder="请输入手机号码"/>
        </section>

        <section class="group-ipt" style="position: relative;">
            <input type="text" id="code" class="reset_pwd_ipt pleft" placeholder="短信验证码" />
            <input type="button" class="get-code" onclick="sendemail()" value="获取验证码" />
        </section>
        <section class="group-ipt">
            <input type="password" id="password" class="reset_pwd_ipt" placeholder="登录密码" />
        </section>
		<section class="group-ipt">
            <input type="text" id="p_mobile" class="reset_pwd_ipt"  placeholder="请输入邀请码"/>
        </section>
        <section class="group-ipt mt24">
            <input type="button" onclick="region()" value="注册" class="complete_btn" />
            <p class="agree">注册代表你已同意 <a href="javascript:;" class="protocol">“戈仑埠用户协议”</a></p>
        </section>

    </div>
</body>
</html>